#include <types.h>
#include <queue.h>

#include <sys/kmalloc.h>
#include <sys/unistd.h>
#include <sys/event.h>

int event_init(event_t *evt, const char *name)
{
    if (!evt)
	return -1;
	
    queue_init(&evt->waitq);
    if (name) {
	evt->name = (char *)kmalloc(strlen(name)+1, GFP_KERNEL);
	if (!name)
	    return -1;
	    
	bzero(evt->name, strlen(name)+1);
	strcpy(evt->name, name);
    }
    
    return 0;
}

int event_waiting(event_t *evt)
{
    if (!evt)
	return -1;
	
    return (!queue_empty(&evt->waitq));
}
